You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔒 Security Fix: ReDOS Vulnerability in Config.js (CVE-2025-5891)
Summary
This PR fixes a Regular Expression Denial of Service (ReDOS) vulnerability in /lib/tools/Config.js that could allow attackers to cause excessive CPU consumption and potentially crash PM2 applications.
The vulnerability exists in the _valid() function (lines 181-185) where a complex regular expression with nested quantifiers is used to parse configuration strings:
Please don't use AI to write the text of your pull requests. This text is so clearly AI-generated. AI writes a lot of repetitive nonsense that has to be read in full, wasting everyone's time, and since AI hallucinates, it also tends to mean people aren't necessarily confident that everything written is true.
Is this pull request just a duplicate of fix:Potential ReDoS Vulnerability or Inefficient Regular Expression in Project: Need for Assessment and Mitigation #5971 ? We've had a fix for this vulnerability for months. Why should this PR be merged instead of that one? That one also includes tests to prevent this kind of thing from occurring in the future, and modifies Config.js much less verbosely, meaning its changes are more legible compared to ripping out the RegExp entirely and replacing it with a more verbose validation function.
I know from working on some internal parts of this project in the past that it can take a while for pull requests to be merged. That's no reason to waste everyone's time with AI slop.
@OIRNOIR
I understand your concern, on using AI. I found this vulnerability and I wanted my repo clean, so I raised this PR.
I did not know that #5971 is already created. I did not mean to waste anybody's time. I just want the vulnerability to be fixed.
If this PR is not efficient, maintainers can feel free to reject this and I will close it :)
PS: I used multiple agents and I verified what AI generated before I pushed, I did not do this blindly.
Also, you can include your first point in CONTRIBUTING.md, if maintainers feel the same way, they will merge it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔒 Security Fix: ReDOS Vulnerability in Config.js (CVE-2025-5891)
Summary
This PR fixes a Regular Expression Denial of Service (ReDOS) vulnerability in
/lib/tools/Config.jsthat could allow attackers to cause excessive CPU consumption and potentially crash PM2 applications.🚨 Vulnerability Details
Affected Code
The vulnerability exists in the
_valid()function (lines 181-185) where a complex regular expression with nested quantifiers is used to parse configuration strings:This regex pattern exhibits exponential time complexity when processing specially crafted input strings, leading to catastrophic backtracking.
Attack Scenario
An attacker could:
🛠️ Fix Implementation
This PR implements multiple layers of protection:
1. Regex Complexity Validation
/([+*]{2,}|(\(.{0,10}\)){3,})/2. Input Sanitization
3. Defensive Programming
validateJSON()function📋 Changes Made
/lib/tools/Config.jsvalidateJSON()✅ Testing
🔗 References
📈 Impact
This fix:
🚀 Deployment
Safe to deploy immediately - this is a security-critical fix with no breaking changes.